package cn.itcast.aspect;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.Signature;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

//@Component
//@Aspect
public class CalculationTimeAspect {

//    @Around("execution(* cn.itcast.service.impl.*.*(..))")
    public Object CalculationTimeAspect(ProceedingJoinPoint pjp) throws Throwable {
        long start = System.currentTimeMillis();
        Object rsult = pjp.proceed();
        long end = System.currentTimeMillis();
        Signature signature = pjp.getSignature();
        String name = signature.getName();
        String className = signature.getDeclaringTypeName();
        System.out.println(className + "." + name + "耗时:" + (end - start));
        return rsult;
    }
}
